<?php

namespace App\Http\Requests\Home;

use Illuminate\Foundation\Http\FormRequest;

class CreateOrderAddress extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'getname' => 'required|',
            'addressdetail' => 'required|min:2|max:50',
            'phone' => 'required|regex:/^1[34578][0-9]{9}$/',
        ];
    }

    public function messages()
    {
        return [
            'getname.required' => '收件人不能为空',
            'addressdetail.required' => '具体收件地址不能为空',
            'addressdetail.min' => '具体收件地址最少2个字节',
            'addressdetail.max' => '具体收件地址最多50个字节',
            'phone.required' => '收件人号码不能为空',
            'phone.regex' => '收件人手机号码填写不正确',
        ];
    }
}
